#include "func.h"
#include <string.h>
#include <iostream>
#include <shadow.h>
#include <crypt.h>
using std::cout;
using std::endl;
using namespace std;
#include "MySQLClient.hpp"
#include <cstdlib>
#include <mysql/mysql.h>

int main()
{
    using namespace wd;
    MySQLClient myclient;
    
    // 使用与服务器配置一致的参数
    bool ret = myclient.connect("192.168.15.128", 3306, "root", "1234", "gmy");
    if(!ret) {
        std::cerr << "数据库连接失败！" << std::endl;
        return EXIT_FAILURE;
    }

    std::cout << "数据库连接成功！" << std::endl;

    // 测试插入操作
    string sql1 = "INSERT INTO Students (name, age, class) VALUES ('张三', 20, '高三(1)班')";
    if(myclient.writeOperationQuery(sql1)) {
        std::cout << "插入操作成功" << std::endl;
    } else {
        std::cout << "插入操作失败" << std::endl;
    }
    
    // 测试查询操作
    string sql2 = "select * from Students";
    vector<vector<string>> res = myclient.readOperationQuery(sql2);
    MySQLClient::dump(res);

    return 0;
}




























































